//
//  NavigationController.m
//  PocketTutor
//
//  Created by jarze on 15/6/9.
//  Copyright (c) 2015年 jarze. All rights reserved.
//

#import "NavigationController.h"
#import "UIBarButtonItem+Extension.h"





//#define PTNavigationTitleFont [UIFont boldSystemFontOfSize:20]

@interface NavigationController ()

@end

@implementation NavigationController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"BG Nav"] forBarMetrics:UIBarMetricsDefault];
    [self.navigationBar setShadowImage:nil];
}

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if(self) {
        
    }
    return self;
}

+(void)initialize
{
    
    [self setupNavigationBarTheme];
    
    [self setupBarButtonItemTheme];
    
    
    
}
+(void)setupNavigationBarTheme
{
    

    UINavigationBar *appearance = [UINavigationBar appearance];
//    [appearance setBackgroundImage:[UIImage imageNamed:@"BG Nav"] forBarMetrics:UIBarMetricsDefault];
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    textAttrs[NSFontAttributeName] = PTHelveticaNeueMedium17;
    
    [appearance setTitleTextAttributes:textAttrs];
}

+(void)setupBarButtonItemTheme
{
    UIBarButtonItem *appearence = [UIBarButtonItem appearance];
    
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    [appearence setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    
    
    [appearence setBackButtonBackgroundImage:[UIImage imageNamed:@"navigation_button_background"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if(self.viewControllers.count>0){
        
        
        viewController.hidesBottomBarWhenPushed = YES;
        
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back" highImageName:@"navigationbar_back" target:self action:@selector(back)];
        
    }
    [super pushViewController:viewController animated:animated];
}

-(void)back
{
    [self popViewControllerAnimated:YES];
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"BG Nav"] forBarMetrics:UIBarMetricsDefault];
//    [UIApplication sharedApplication].statusBarHidden = NO;
    
}


@end
